<template>
  <div class="register">
    <div class="zzt" @click="login" v-if="geren == 'false'">登录</div>
    <div class="zzt" @click="register" v-if="geren == 'false'">注册</div>
    <login1 v-if="login1 == 'ture'" class="login1" />
    <register1 v-if="register1 == 'ture'" class="register1" />
    <div v-if="geren == 'true'" class="geren">
      <div v-if="touxing = false">11111</div>
      <img :src="touxiang" alt="" class="touxiang" v-if="touxiang" />
      <div class="text8" v-if="touxiang">{{ username }}</div>
      <div class="zzt2" @click="tuichu" v-if="touxiang">注销</div>
    </div>
  </div>
</template>

<script>
import login1 from "../../login/Login.vue";
import register1 from "../../register/Register.vue";

export default {
  data() {
    return {
      login1: "false",
      register1: "false",
      geren: "false",
      touxiang: "",
      username: "",
    };
  },
  components: {
    login1,
    register1,
  },
  methods: {
    login() {
      this.login1 = "ture";
      localStorage.clear();
    },
    register() {
      this.register1 = "ture";
    },
    tuichu() {
      this.geren = "false";
      localStorage.clear();
      this.touxiang = ""
      this.username = ""
    },
  },
  mounted() {
    let kaiguang = window.localStorage.getItem("islogin");
    // console.log(kaiguang);
    if (kaiguang) {
      this.geren = "true";
    }
    this.$axios("/zztz/finduser").then((res) => {
      this.touxiang = res.data[0].touxiang;
      // console.log(this.touxiang);
      this.username = res.data[0].username;
    });
  },
};
</script>

<style scoped="scoped">
.register {
  width: 301px;
  height: 260px;
  box-sizing: border-box;
  background-color: rgb(245, 246, 245);
  position: absolute;
  right: 20px;
  top: 0px;
  padding: 70px;
  padding-top: 77px;
}
.zzt {
  width: 150px;
  height: 40px;
  text-align: center;
  line-height: 40px;
  color: #fff;
  background-color: #dd3915;
  margin-bottom: 10px;
  cursor: pointer;
}
.login1 {
  left: 0px;
  top: 0px;
  z-index: 99;
  width: 100%;
  height: 100%;
}
.register1 {
  left: 0px;
  top: 0px;
  z-index: 99;
  width: 100%;
  height: 100%;
}
.geren {
  width: 100%;
  height: 100%;
  /* background-color: rebeccapurple; */
}
.geren img {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  margin-left: 44px;
}
.text8 {
  font-size: 18px;
  color: #dd3915;
  text-align: center;
  /* margin: 0 auto; */
  margin-top: 20px;
  cursor: pointer;
}
.touxiang {
  cursor: pointer;
}
.zzt2 {
  width: 50px;
  height: 20px;
  text-align: center;
  line-height: 20px;
  color: #fff;
  background-color: #dd3915;
  margin-bottom: 10px;
  cursor: pointer;
  margin-left: 147px;
  margin-top: 33px;
}
</style>